package com.squirrel.common.service.impl;

import com.squirrel.common.entity.Banner;
import com.squirrel.common.exception.BaseException;
import com.squirrel.common.mapper.BannerMapper;
import com.squirrel.common.response.code.CodeEnum;
import com.squirrel.common.service.BannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * BannerServiceImp 轮播图服务实现类
 * </p>
 *
 * @author 关远键
 * @since 2021/11/11 16:06
 */
@Service
public class BannerServiceImp extends ServiceImpl<BannerMapper, Banner> implements BannerService {

    @Autowired
    private BannerMapper bannerMapper;

    /**
     * 获取轮播图
     * @author 关远键
     * @date 2021/11/14 10:52
     * @return java.util.List<com.squirrel.common.entity.Banner>
     */
    @Override
    public List<Banner> getList() {

        List<Banner> list = bannerMapper.getList();

        if (null == list) {
            throw new BaseException(CodeEnum.NON_RESOURCE);
        }

        return list;
    }

}
